package mall.kotlin.com.myapplication.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;

/**
 * USER: zjw
 * DATA: 2018/11/14 0014
 * TIME: 上午 9:51
 */
public class CustomTextView extends android.support.v7.widget.AppCompatTextView {
    Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    public CustomTextView(Context context) {
        super(context);
        intDraw();
    }

    public CustomTextView(Context context,  AttributeSet attrs) {
        super(context, attrs);
        intDraw();
    }

    public CustomTextView(Context context,  AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        intDraw();
    }

    private void intDraw() {
        mPaint.setColor(Color.RED);
        mPaint.setStrokeWidth(1.5f);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int wd = getWidth();
        int ht = getHeight();
        canvas.drawLine(0,ht/2,wd,ht/2,mPaint);
    }
}
